<?php
/**
	* M_cache
	* 缓存管理类
	* @package Package Name
	* @subpackage Subpackage
	* @category Category
	* @author YinChuan  [hot530@126.com]
	* @link http://www.530Net.com
*/
class Cache_contro extends MY_Controller {

	function __construct()
	{
		parent::__construct();	
	}
	
	function index()
	{
	}
	
	
	// ------------------------------------------------------------------------
	
	/**
		* 更新注册区域
	*/
	public function cacheup($vclass = 1)
	{
		$data = $this->data_config;
		$data['vtitle'] = $vclass;
		$this->load->view('cache/cache_view',$data);		
	}
	
	


	// ------------------------------------------------------------------------
	
	/**
		* 更新注册区域

	*/
	public function addressup()
	{
		$filename = "reg_area.js";
		$this->load->model('cache_model');
			$filedata = "var AddressTree={};AddressTree[\"a_row\"]=new Array(); with(AddressTree){";
			$list = $this->cache_model -> addressup();
			foreach($list->result() as $row):
				$filedata .= "a_row[\"$row->region_id\"]=[\"$row->region_name\",$row->parent_id,$row->region_type];";
			endforeach;
			$filedata .= "}";
		$this->load->helper('file');
		$filepath = str_replace("\\","/",FCPATH)."cache/js/".$filename;	
		write_file($filepath, $filedata);
		header("content-type:text/html;charset=utf-8");echo '<script>alert("更新成功");history.back();</script>';
		
	}
	
	
	// ------------------------------------------------------------------------
	
	/**
		* 更新注册区域（详细）

	*/
	public function addressdetailup()
	{
		$filename = "reg_areadetail.js";
		$this->load->model('cache_model');
			$filedata = "var addressdetail={};addressdetail[\"a_row\"]=new Array(); with(addressdetail){";
			$list = $this->cache_model -> addressup2();
			foreach($list->result() as $row):
				$filedata .= "a_row[\"$row->region_id\"]=[\"$row->region_name\",$row->parent_id,$row->region_type];";
			endforeach;
			$filedata .= "}";
		$this->load->helper('file');
		$filepath = str_replace("\\","/",FCPATH)."cache/js/".$filename;	
		write_file($filepath, $filedata);
		header("content-type:text/html;charset=utf-8");echo '<script>alert("更新成功");history.back();</script>';
		
	}	
	
	// ------------------------------------------------------------------------
	
	/**
		* 区域分类（搜索）

	*/

	public function Saddressdetailup()
	{
		$filename = "s_areadetail.js";
		$this->load->model('cache_model');
			$filedata = "var t_areaObj = new Array();";
			$list = $this->cache_model -> addressup2();
			$i = 0;
			// t_areaObj["0"]=new Array("上海","0","1");  // 名称，父id, id
			foreach($list->result() as $row):
				$filedata .= "t_areaObj[\"" . $i . "\"]=new Array(\"$row->region_name\",\"$row->parent_id\",\"$row->region_id\"); ";
				$i ++;
			endforeach;
		$this->load->helper('file');
		$filepath = str_replace("\\","/",FCPATH)."cache/js/".$filename;	
		write_file($filepath, $filedata);
		header("content-type:text/html;charset=utf-8");echo '<script>alert("更新成功");history.back();</script>';
	}
	





	
	
	// ------------------------------------------------------------------------
	/**
		* 更新家具分类
	*/
	public function jiajuclassup()
	{
		$filename = "jiajuclass.js";
		$this->load->model('cache_model');
			$filedata = "var jiajuclass={};jiajuclass[\"a_row\"]=new Array(); with(jiajuclass){";
			$list = $this->cache_model ->jiajuclassup();
			foreach($list->result() as $row):
				$filedata .= "a_row[\"$row->classid\"]=[\"$row->classname\",$row->classtopid,0];";
			endforeach;
			$filedata .= "}";
		$this->load->helper('file');
		$filepath = str_replace("\\","/",FCPATH)."cache/js/" .$filename;	
		write_file($filepath, $filedata);
		header("content-type:text/html;charset=utf-8");echo '<script>alert("更新成功");history.back();</script>';
	}
	

	// ------------------------------------------------------------------------
	/**
		* 家具分类（搜索）
	*/
	public function Sjiajuclassup()
	{
		$filename = "s_jiajuclass.js";
		$this->load->model('cache_model');
			$filedata = "var t_jiajuclass = new Array();";
			$list = $this->cache_model ->jiajuclassup();
			$i = 0;
			// t_areaObj["0"]=new Array("上海","0","1");  // 名称，父id, id
			foreach($list->result() as $row):
				$filedata .= "t_jiajuclass[\"" . $i . "\"]=new Array(\"$row->classname\",\"$row->classtopid\",\"$row->classid\"); ";
				$i ++;
			endforeach;
		$this->load->helper('file');
		$filepath = str_replace("\\","/",FCPATH)."cache/js/".$filename;	
		write_file($filepath, $filedata);
		header("content-type:text/html;charset=utf-8");echo '<script>alert("更新成功");history.back();</script>';
	}
	















	
	
}




